// 混淆数组
const _0x4f2d = ['getTime', 'toString', 'charCodeAt', 'fromCharCode', 'split', 'join', 'reverse', 'slice'];

// 基础加密函数
const _0x2e1f = (str) => {
  return str[_0x4f2d[1]](16);
};

// 字符串混淆
const _0x3d8a = (str) => {
  let result = '';
  for (let i = 0; i < str.length; i++) {
    result += String[_0x4f2d[3]](str[_0x4f2d[2]](i) ^ 0x7F);
  }
  return result;
};

// 时间戳加密
const _0x5b2c = (timestamp) => {
  const key1 = 0x7F3A9B2C;
  const key2 = 0x4D2E8F1A;
  const key3 = 0x9C5B3D7E;
  
  let result = timestamp;
  result = result ^ key1;
  result = result ^ key2;
  result = result ^ key3;
  
  const str = result[_0x4f2d[1]]();
  const arr = str[_0x4f2d[4]]('');
  arr[_0x4f2d[6]]();
  return arr[_0x4f2d[7]](0, 8)[_0x4f2d[5]]('');
};

// 时间戳解密
const _0x6d3e = (encrypted) => {
  const key1 = 0x7F3A9B2C;
  const key2 = 0x4D2E8F1A;
  const key3 = 0x9C5B3D7E;
  
  const arr = encrypted[_0x4f2d[4]]('');
  arr[_0x4f2d[6]]();
  let result = parseInt(arr[_0x4f2d[5]](''), 16);
  
  result = result ^ key3;
  result = result ^ key2;
  result = result ^ key1;
  
  return result;
};

// 预计算的时间戳（经过多层加密）
const _0x8f7d = '7d4e2f1a';

// 导出函数
const encryptTime = (date) => {
  const timestamp = date[_0x4f2d[0]]();
  return _0x5b2c(timestamp);
};

const decryptTime = (encryptedTime) => {
  const timestamp = _0x6d3e(encryptedTime);
  return new Date(timestamp);
};

// 导出常量（使用混淆后的变量名）
const UNLOCK_TIMESTAMP = _0x8f7d;

module.exports = {
  encryptTime,
  decryptTime,
  UNLOCK_TIMESTAMP
}; 